package me.xiaoyan.android.widget;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DataStore implements Serializable {
	private static final long serialVersionUID = 3174177819010451465L;
	private Map<String, Object> maps = new HashMap<String, Object>();

	public List<?> getList(String key) {
		return (List<?>) maps.get(key);
	}
	public Object getObject(String key) {
		return maps.get(key);
	}
	
	public Map<String, Object> getAll(){
		return maps;
	}

	public String getString(String key) {
		if (maps.get(key) != null) {
			return maps.get(key).toString();
		}
		return null;
	}

	public int getInt(String key) {
		String data = this.getString(key);
		return data != null ? Integer.parseInt(data) : 0;
	}

	public boolean getBoolean(String key, boolean b) {
		String data = this.getString(key);
		return data != null ? Boolean.parseBoolean(this.getString(key)) : b;
	}

	public void setList(String key, List<?> list) {
		maps.put(key, list);
	}

	public void setString(String key, String value) {
		maps.put(key, value);
	}

	public void setInt(String key, int value) {
		maps.put(key, value);
	}

	public void setBoolean(String key, boolean value) {
		maps.put(key, value);
	}

	public void setData(String key, Object value) {
		maps.put(key, value);
	}
}
